package com.exam.controller;

import com.exam.pojo.ApiResult;
import com.exam.pojo.FillQuestion;
import com.exam.service.FillQuestionService;
import com.exam.serviceImpl.FillQuestionServiceImpl;
import com.exam.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FillQuestionController {
    @Autowired
    private FillQuestionService fillQuestionService;
    @GetMapping("/fillQuestionId")
    public ApiResult findOnlyQuestionId(){
    FillQuestion res=fillQuestionService.findOnlyQuestionId();
    if (res!=null) {
        return ApiResultHandler.buildApiResult(200, "查询成功", res);
        }
    return ApiResultHandler.buildApiResult(400, "查询失败", res);
    }
    @PostMapping("/fillQuestion")
    public ApiResult add(@RequestBody FillQuestion fillQuestion){
        int res=fillQuestionService.add(fillQuestion);
        if(res!=0){
            return ApiResultHandler.buildApiResult(200, "添加成功", res);
        }
        return ApiResultHandler.buildApiResult(400, "添加失败", res);
    }


}
